import { DisableDto, DisableRes, PageDto, PageData, PutDto, PutRes } from "~/rest";

import { getGateway } from "@/droplet-bus/core.define";
import { Gateway } from "@/droplet-bus/core.define";

import { app_gateway } from "./core.local";
import { GemTpl } from "./schema.gem";
import { MarketOrder } from "./schema.order";

export const GemTplGateway: Gateway = getGateway(app_gateway, "river_market_gem_tpl");
export type getGemTplDto = PageDto<GemTpl>;
export type putGemTplDto = PutDto<GemTpl>;
export type deleteGemTplDto = DisableDto;

export interface GemTplInterfaceWithPrimary<T> {
  /** 用户准备购买钻石，需要查看商品列表 */
  getGemTpl(dto: T & getGemTplDto): Promise<PageData<GemTpl>>;
  /** 超级管理员创建/修改商品模板 */
  putGemTpl(dto: T & putGemTplDto): Promise<PutRes<GemTpl>>;
  /** 超级管理员删除商品模板 */
  deleteGemTpl(dto: T & deleteGemTplDto): Promise<DisableRes>;
}

export const GemSkuGateway: Gateway = getGateway(app_gateway, "river_market_gem_sku");
export type postGemSkuDto = { tplId: GemTpl["id"] };

export interface GemSkuInterfaceWithDerive<T> {
  /** 用户根据商品模板创建订单（运营中心运出钻石）*/
  postGemSku(dto: T & postGemSkuDto): Promise<PutRes<MarketOrder>>;
}
